import request from '@/utils/request'

/**
 * 自动排班接口
 * @param {deptId, startTime, endTime} data 
 * @returns 
 */
export function autoMakeDuty(data) {
  return request({
    url: '/duty/schedule/autoDuty',
    method: 'post',
    data: data
  })
}

/**
 * 发布排班表
 * @param {scheduleId,status} data 
 * @returns 
 */
export function pushDuty(data) {
  return request({
    url: '/duty/schedule',
    method: 'put',
    data: data
  })
}

/**
 * 获取排班计划列表
 * @param {*} query 
 * @returns 
 */
export function listForce(query) {
  return request({
    url: '/duty/schedule/list',
    method: 'get',
    params: query
  })
}

/**
 * 查询排班表
 * @param {*} scheduleId 
 * @returns 
 */
export function getScheduleDetail(scheduleId) {
  return request({
    url: '/duty/schedule/getshiftmembers/' + scheduleId,
    method: 'get'
  })
}

/**
 * 清除指定班次的排班数据
 * @param {dutyDate,scheduleId,shiftCode} data 
 * @returns 
 */
export function delWorkforceMember(data) {
  return request({
    url: '/duty/member/delete',
    method: 'DELETE',
    data: data
  })
}

/**
 * 根据部门和角色ID查询值班人员
 * @param {deptId, titleCode} data 
 * @returns 
 */
export function getDutyMember(data) {
  return request({
    url: '/duty/config/selectByTitleCode',
    method: 'get',
    params: data
  })
}

/**
 * 添加值班人员
 * @param {dutyDate,scheduleId,shiftCode,userId} data 
 * @returns 
 */
export function addDutyMember(data) {
  return request({
    url: '/duty/member',
    method: 'post',
    data: data
  })
}

/**
 * 添加排班计划
 * @param {*} data 
 * @returns 
 */
export function addDuty(data) {
  return request({
    url: '/duty/schedule',
    method: 'post',
    data: data
  })
}

/**
 * 获取排班计划列表
 * @param {*} query 
 * @returns 
 */
export function getDutyList(query) {
  return request({
    url: '/duty/schedule/list',
    method: 'get',
    params: query
  })
}

/**
 * 获取部门排班计划列表
 * @param {*} query 
 * @returns 
 */
export function getDeptyDutyList() {
  return request({
    url: '/duty/schedule/selectByLeader',
    method: 'get',
  })
}

/**
 * 部门添加排班计划
 * @param {*} data 
 * @returns 
 */
export function addDeptDuty(data) {
  return request({
    url: '/duty/shift',
    method: 'post',
    data: data
  })
}

/**
 * 获取部门排班列表
 * @param {*} scheduleId 
 * @returns 
 */
export function getDeptyDutyShiftList(scheduleId) {
  return request({
    url: '/duty/shift/list?scheduleId=' + scheduleId,
    method: 'get',
  })
}

/**
 * 删除排班计划
 * @param {*} data 
 * @returns 
 */
export function deleteDuty(scheduleId) {
  return request({
    url: '/duty/schedule/' + scheduleId,
    method: 'DELETE'
  })
}

/**
 * 删除部门排班计划
 * @param {*} scheduleId 
 * @returns 
 */
export function deleteDeptDuty(shiftId) {
  return request({
    url: '/duty/shift/' + shiftId,
    method: 'DELETE'
  })
}

/**
 * 获取排班配置列表
 * @returns 
 */
export function getShiftConfigList() {
  return request({
    url: '/duty/shiftConfig/list',
    method: 'get',
  })
}

// 新增班次配置
export function addShiftConfig(data) {
  return request({
    url: '/duty/shiftConfig',
    method: 'post',
    data: data
  })
}

// 修改班次配置
export function updateShiftConfig(data) {
  return request({
    url: '/duty/shiftConfig',
    method: 'put',
    data: data
  })
}

// 删除班次配置
export function delShiftConfig(scId) {
  return request({
    url: '/duty/shiftConfig/' + scId,
    method: 'delete'
  })
}